'use strict';

define(['controllers', '../service/menuService', '../../home/service/loginService'], function (controllers) {
    controllers.common.controller('IndexController', ['$scope', '$rootScope', '$location', 'MenuService', 'LoginService', function ($scope, $rootScope, $location, menuService, loginService) {
        $scope.currentPath = $location.path();
        $scope.currentMenuUrl = menuService.getOriginMenuUrl($scope.currentPath);
        $scope.$on('$locationChangeSuccess', function (event, path) {
            $scope.currentPath = $location.path();
            $scope.currentMenuUrl = menuService.getOriginMenuUrl($scope.currentPath);
        });

        $scope.logout = function () {
            loginService.logout(function () {
                menuService.reloadMenus($rootScope);
                $location.path('/login');
            });
        };
    }]);
});